﻿#pragma once
#include "../3rdparty/pugixml/pugixml.hpp"

#include "zyWidget.h"
#include "zyEditBox.h"//编辑框类
#include "zyGroupBox.h"
#include "zyRadioBox.h"
#include "zyCheckBox.h"
#include "zyStatic.h"
#include "zyComboBox.h"
#include "zyScrollBar.h"
#include "zyPictureBox.h"
#include "zyTreeView.h"
#include "zyToolBar.h"
#include "zyUpDown.h"
#include "zyTabControl.h"
#include "zyStatusBar.h"
#include "zyProgressBar.h"
#include "zyTrackBar.h"
#include "zyPropertyGrid.h"
#include "zyListView.h"
#include "zyShapeBox.h"
#include "zyCheckB3State.h"
#include "zyComboBoxEx.h"
#include "zyListBoxEx.h"
#include "zyDateTimePick.h"
#include "zyIPAddress.h"
#include "zyHotkeyBox.h"
#include "zyLinkBox.h"
#include "zyAnimateBox.h"
#include "zyAlphaLabel.h"
#include "zyButtonEx.h"

namespace DarkMoonUI {

	std::wstring base64_encode(const std::vector<unsigned char>& input);
	std::vector<BYTE> base64_decode(const std::wstring& Data);

	constexpr const wchar_t* 资源名_名称 = L"name";
	constexpr const wchar_t* 资源名_矩形 = L"rect";
	constexpr const wchar_t* 资源名_标题 = L"text";
	constexpr const wchar_t* 资源名_窗口风格 = L"style";
	constexpr const wchar_t* 资源名_扩展风格 = L"styleex";
	constexpr const wchar_t* 资源名_不在任务栏显示 = L"hideTaskbar";
	constexpr const wchar_t* 资源名_类名 = L"classname";
	constexpr const wchar_t* 资源名_ID = L"id";
	constexpr const wchar_t* 资源名_ZY窗口风格 = L"ZY窗口风格";
	constexpr const wchar_t* 资源名_鼠标指针 = L"鼠标指针";
	constexpr const wchar_t* 资源名_图标 = L"图标";
	constexpr const wchar_t* 资源名_字体 = L"字体";
	constexpr const wchar_t* 资源名_图片组 = L"图片组";
	constexpr const wchar_t* 资源名_图片组_易格式 = L"易格式";
	constexpr const wchar_t* 资源名_边框 = L"border";
	constexpr const wchar_t* 资源名_文本色 = L"文本色";
	constexpr const wchar_t* 资源名_背景色 = L"背景色";
	constexpr const wchar_t* 资源名_背景图 = L"背景图";
	constexpr const wchar_t* 资源名_背景图显示方式 = L"背景图显示方式";
	constexpr const wchar_t* 资源名_内容 = L"内容";

	class zyXMLRes : public  zyRes
	{
	protected:
		struct XmlResCreateStruct {
			int x;
			int y;
			int cx;
			int cy;
			int style;
			int ExStyle;
			std::wstring lpszName;
			int id;
			int flages;
		};
		struct StatusBarItem {
			std::wstring 标题;
			std::wstring 提示文本;
			zyIcon* 图标;
			int 图片索引;
			//std::vector<int> 宽度;
		};
		int XRF_rect = 1;
		int XRF_style = 2;
		int XRF_exStyle = 4;
		int	XRF_id = 8;
		int	XRF_name = 16;

	public:
		zyXMLRes();
		~zyXMLRes();
		bool Initialize();
		bool LoadXml(const std::wstring& xmlContent);
		std::wstring 取Xml(bool 参数_自动格式 = true);

		bool 载入菜单栏(const std::wstring& 参数_资源名, zyMenu& 参数_菜单);
		bool 载入弹出菜单(const std::wstring& 参数_资源名, zyMenu& 参数_菜单);
		bool 创建窗口(HWND 参数_父窗口, /* const std::wstring& 参数_XML, */ const std::wstring & 参数_资源名, zyWidget& 参数_窗口);
		bool 载入快捷键(const std::wstring& name, zyAccelTable& acc);
	protected:
		static void  WINAPI zyXMLRes_Destroy(resObject* obj);

		void _OnXmlresCreate(zyWidget* form, pugi::xml_node* root);
		void xml_SetWinPropertie(zyWidget* form, pugi::xml_node* root);
		void xml_ParseNodeCreateControl(pugi::xml_node* pnode, HWND parent, HWND childhWnd);
		void* xml_AddControl(zyWindow *child, pugi::xml_node node);
		
		bool xml_LoadMenu(const std::wstring& name, zyMenu& menu);
		void xml_LoadMenuItem(pugi::xml_node node, zyMenu& Menu);
		bool xml_LoadSubMenu(const std::wstring& name, zyMenu& menu);
		bool xml_LoadImageList(const std::wstring& name, zyLmageList& imageList);
		bool xml_GetIcon(const std::wstring& value, zyIcon& icon);

		void xml_GetCtrolCreateStruct(pugi::xml_node node, XmlResCreateStruct& xrcs) const;

		void XMLRES_置控件属性(zyWindow* contorl, pugi::xml_node hNode);

		void XMLRES_置编辑框属性(zyEditBox* pbtn, pugi::xml_node node);
		void XMLRES_置按钮属性(zyButton* pbtn, pugi::xml_node node);
		
		HWND XMLRES_创建按钮(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		HWND XMLRES_创建编辑框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);

		HWND XMLRES_创建分组框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置分组框属性(zyGroupBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建单选框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置单选框属性(zyRadioBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建选择框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置选择框属性(zyCheckBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建标签(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置标签属性(zyStatic* ptr, pugi::xml_node node);

		HWND XMLRES_创建组合框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置组合框属性(zyComboBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建列表框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置列表框属性(zyListBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建滚动条(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置滚动条属性(zyScrollBar* ptr, pugi::xml_node node);

		HWND XMLRES_创建图片框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置图片框属性(zyPictureBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建树型框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置树型框属性(zyTreeView* ptr, pugi::xml_node node);
		void XMLRES_树型框加入项目(zyTreeView* ptr, pugi::xml_node node, HTREEITEM treeNode);

		HWND XMLRES_创建工具条(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置工具条属性(zyToolBar* ptr, pugi::xml_node node);

		HWND XMLRES_创建调节器(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置调节器属性(zyUpDown* ptr, pugi::xml_node node);

		HWND XMLRES_创建选择夹(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置选择夹属性(zyTabControl* ptr, pugi::xml_node node);

		zyPanel* XMLRES_创建面板(HWND parent, XmlResCreateStruct& res, pugi::xml_node node);
		void XMLRES_置面板属性(zyPanel* ptr, pugi::xml_node node);

		HWND XMLRES_创建状态栏(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置状态栏属性(zyStatusBar* ptr, pugi::xml_node node);

		HWND XMLRES_创建进度条(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置进度条属性(zyProgressBar* ptr, pugi::xml_node node);

		HWND XMLRES_创建滑块条(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置滑块条属性(zyTrackBar* ptr, pugi::xml_node node);

		HWND XMLRES_创建超级列表框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置超级列表框属性(zyListView* ptr, pugi::xml_node node);
		int XMLRES_超级列表框插入表项(zyListView* ptr, pugi::xml_node node, int iGroupId);

		HWND XMLRES_创建外形框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置外形框属性(zyShapeBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建选择框三态(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置选择框三态属性(zyCheckB3State* ptr, pugi::xml_node node);

		HWND XMLRES_创建图像组合框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置图像组合框属性(zyComboBoxEx* ptr, pugi::xml_node node);

		HWND XMLRES_创建选择列表框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置选择列表框属性(zyListBoxEx* ptr, pugi::xml_node node);

		HWND XMLRES_创建月历(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置月历属性(zyMonthCal* ptr, pugi::xml_node node);

		HWND XMLRES_创建日期框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置日期框属性(zyDateTimePick* ptr, pugi::xml_node node);

		HWND XMLRES_创建IP编辑框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置IP编辑框属性(zyIPAddress* ptr, pugi::xml_node node);

		HWND XMLRES_创建热键框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置热键框属性(zyHotkeyBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建超链接框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置超链接框属性(zyLinkBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建影像框(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置影像框属性(zyAnimateBox* ptr, pugi::xml_node node);

		HWND XMLRES_创建透明标签(HWND parent, XmlResCreateStruct& xrcs, pugi::xml_node hNode);
		void XMLRES_置透明标签属性(zyAlphaLabel* ptr, pugi::xml_node node);
	};

}

